﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="index.aspx.cs" Inherits="person_index" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../css/ext-all.css" />
    <link rel="stylesheet" type="text/css" href="../css/efs-all.css" />
    <script type="text/javascript" src="../js/loadmask.js"></script>
    <script type="text/javascript" src="../js/efs-all.js"></script>
    <script language="JavaScript">

        var g_XML = Efs.Common.getQryXml();

        var sPersonID = "";
        function doGridClick(data) {
            sPersonID = data["STUDENTID"]
            if (sPersonID != "") {
                Efs.getExt("cmdEdit").enable();
                Efs.getExt("cmdDel").enable();
            }
        }

        // 进入查询
        function doQry() {
            var strXml = Efs.Common.getQryXml(Efs.getExt("frmQry"));
            Efs.getDom("psnList").setAttribute("txtXML",strXml);
            Efs.getExt("psnGrid").store.load();
        }

        function onAddEx(){
            Efs.getExt("frmPost").reset();
            Efs.getDom("studentid").setAttribute("operation","0");
            Efs.getDom("studentid").setAttribute("state","0");
            Efs.getDom("frmPost").setAttribute("url","../sysadmin/baseRefWeb.aspx?method=studentAdd");
            with(Efs.getExt("studentWindow")){
                setTitle("添加学员");
                show();
            }
        }

        // 修改人员档案
        function onEditEx() {

            if (sPersonID == "") {
                alert("没有选择学员");
                return false;
            }
            
            xmlhttp.Open("POST", "" + sPersonID, false);
            xmlhttp.Send();
            var xmlReturnDoc = new ActiveXObject("MSXML2.DOMDocument");
            xmlReturnDoc = xmlhttp.responseXML;
            Efs.Common.setEditValue(xmlReturnDoc.xml, Efs.getExt("frmData"), "QUERYINFO");
            xmlReturnDoc = null;
            xmlhttp = null;


            Efs.getExt("frmData").reset();
            Efs.Common.ajax("../sysadmin/baseRefWeb.aspx?method=studentDetail&txtPersonID=" + classid, "", function (succ, xml_http, options) {
                if (succ) { // 是否成功
                    var xmlReturnDoc = xml_http.responseXML;
                    Efs.Common.setEditValue(xmlReturnDoc, Efs.getExt("frmPost"), "QUERYINFO");
                }
                else {
                    alert("加载数据失败!");
                }
            });
            // 注意这里是getDom
            Efs.getDom("frmPost").setAttribute("url", "../sysadmin/baseRefWeb.aspx?method=ClassEditOrDel");
            // 下面两个是 getDom  // 修改属性，配置为update操作
            Efs.getDom("classid").setAttribute("operation", "1");
            Efs.getDom("classid").setAttribute("state", "5");
            with (Efs.getExt("classWindow")) {
                setTitle("修改班级");
                show();
            }

        }

        // 提交修改人员信息
        function doPsnEdit() {
            Efs.getExt("frmData").submit();
        }

        // 删除人员信息
        function onDelEx() {

            Efs.getDom("frmPost").setAttribute("url", "../sysadmin/baseRefWeb.aspx?method=studentDel");
            Efs.getExt("frmPost").submit(sPersonID);
        }
        
        function doHide() {
            Efs.getExt("studentWindow").hide();
        }

        function reRet() {
            Efs.getExt("frmPost").reset();
        }

        function doSubmit() {
            Efs.getExt("frmPost").submit();
        }
        // 获取异步提交的返回监听函数
        function frmPostSubBack(bln, from, action) {
            if (bln) {
                Efs.getExt("studentWindow").hide();
                doQry();
            }
            else {
                var xml_http = action.response;
                var objXML = xml_http.responseXML;
                alert("处理失败：" + objXML.selectSingleNode("//FUNCERROR").text);
                objXML = null;
                xml_http = null;
            }
        }
    </script>
</head>
<body>
    <div iconcls="icon-panel" region="north" height="60" title="查询学员列表" border="false">
        <form id="frmQry" method="post">
        <table class="formAreaTop" width="100%" height="100%" cellpadding="0" cellspacing="0">
            <tr>
                <td>
                </td>
                <td width="60">
                    姓名
                </td>
                <td width="160">
                    <input type="text" class="Edit" kind="text" fieldname="NAME" operation="like" maxlength="30"
                        hint="模糊查询">
                </td>
                <td width="40">
                    性别
                </td>
                <td width="160">
                    <input type="text" class="Edit" kind="dic" src="DIC_SEX" fieldname="SEX">
                </td>
                <td width="40">
                    籍贯
                </td>
                <td width="160">
                    <input type="text" class="Edit" kind="dic" src="DIC_CODE" fieldname="PLACECODE">
                </td>
                <td>
                    <input iconcls="icon-qry" type="button" value="查 询" onefsclick="doQry()">
                </td>
                <td>
                    &nbsp;
                </td>
            </tr>
        </table>
        </form>
    </div>
    <div id="psnGrid" region="center" xtype="grid" pagingbar="true" pagesize="25" onefsrowclick="doGridClick()"
        onefsrowdblclick="onEditEx()">
        <div xtype="tbar">
            <span style="font-size: 9pt; font-weight: bold; color: #15428B;">学员列表</span> 
            <div text="->"></div> 
            <div iconcls="icon-add" id="cmdAdd" text="新增学员#A" onefsclick="onAddEx()">
            </div>
            <div text="-">
            </div>
            <div iconcls="icon-edit" id="cmdEdit" text="编辑学员#E" onefsclick="onEditEx()" disabled>
            </div>
            <div text="-">
            </div>            
            <div iconcls="icon-del" id="cmdDel" text="删除学员#D" onefsclick="onDelEx()" disabled>
            </div>
            <div text="-">
            </div>
            <div iconcls="icon-back" text="返 回" onefsclick="top.showTask()">
            </div>
        </div>
        <div id="psnList" xtype="store" url="../sysadmin/baseRefWeb.aspx?method=studentList"
            baseparams="{txtXML:g_XML}" autoload="true">
            <div xtype="xmlreader" fieldid="PERSONID" record="ROW" tabname="PERSON" totalrecords="QUERYINFO@records">
                <div name="STUDENTID" mapping="STUDENTID">
                </div>
                <div name="NAME" mapping="NAME">
                </div>
                <div name="IDCARD">
                </div>
                <div name="CLASSID"></div>
                <div name="SEX">
                </div>
                <div name="PLACECODE">
                </div>
                <div name="BIRTHDAY">
                </div>
                <div name="TEL">
                </div>
                <div name="BAK"></div>
            </div>
        </div>
        <div xtype="colmodel">
            <div type="checkbox">
            </div>
            <div header="学生编码" width="80" sortable="true" dataindex="STUDENTID">
            </div>
            <div header="学生姓名" width="80" sortable="true" dataindex="NAME">
            </div>
            <div header="班级" width="100" sortable="true" dataindex="CLASSID" kind="dic" src="DIC_STUCLASS"></div>
            <div header="身份证号" width="120" sortable="true" dataindex="IDCARD" align="center">
            </div>
            <div header="性别" width="40" sortable="true" dataindex="SEX" kind="dic" src="DIC_SEX">
            </div>
            <div header="籍贯" width="120" sortable="true" dataindex="PLACECODE" kind="dic" src="DIC_CODE"
                align="center">
            </div>
            <div header="出生日期" width="100" sortable="true" dataindex="BIRTHDAY" align="center">
            </div>
            <div header="联系电话" width="100" sortable="true" dataindex="TEL">
            </div>
            <div header="备注" width="200" sortable="false" dataindex="BAK"></div>
        </div>
    </div>
    <div id="studentWindow" xtype="window" width="500" height="257">
        <form id="frmPost" class="efs-box" method="post" url="../sysadmin/baseRefWeb.aspx?method=studentAdd"
        onefssuccess="frmPostSubBack(true)" onefsfailure="frmPostSubBack(false)">
        <table class="formArea">
            <tr>
                <td labelfor="pname" class="text">
                    学生姓名
                </td>
                <td>
                    <input id="pname" type="text" kind="text" fieldname="APT_STUDENT/NAME" state="0" datatype="0"
                        value="" must="true">
                </td>
               
                <td class="text">
                    学生性别
                </td>
                <td>
                    <input type="text" id="xb" kind="dic" src="DIC_SEX" fieldname="APT_STUDENT/SEX" state="0"
                        datatype="0">
                </td>
            </tr>
            <tr>
                 <td class="text">
                    身份证号码
                </td>
                <td>
                    <input type="text" kind="idcard" fieldname="APT_STUDENT/IDCARD" state="0" datatype="0"
                        sex="xb" birthday="csrq">
                </td>
                <td class="text">
                    籍贯
                </td>
                <td>
                    <input type="text" kind="dic" src="DIC_CODE" fieldname="APT_STUDENT/PLACECODE" state="0"
                        datatype="0">
                </td>
            </tr>
            <tr>
                <td class="text">
                    出生日期
                </td>
                <td>
                    <input type="text" id="csrq" kind="date" fieldname="APT_STUDENT/BIRTHDAY" state="0" datatype="3">
                </td>
                <td class="text">
                    电话
                </td>
                <td>
                  <input type="text" kind="text" fieldname="APT_STUDENT/TEL" state="0" datatype="0" />  
                </td>
            </tr>
            <tr>
            <td class="text">班级</td>
            <td colspan="3"><input type="text" kind="dic" fieldname="APT_STUDENT/CLASSID" src="DIC_STUCLASS" state="0" datatype="0" must="true"></td>
            </tr>
            <tr>
                <td class="text">
                    描述
                </td>
                <td colspan="3">
                    <textarea kind="text" style="height: 60px; width: 365px" fieldname="PERSON/BAK" state="0"
                        datatype="0"></textarea>
                </td>
            </tr>
        </table>
        <input id="studentid" type="hidden" kind="text" fieldname="APT_STUDENT/STUDENTID" operation="0"
            writeevent="0" state="0" datatype="0">
        </form>
        <div xtype="buttons">
            <div text="提 交" onefsclick="doSubmit()">
            </div>
            <div text="清 空" onefsclick="reRet()">
            </div>
            <div text="关 闭" onefsclick="doHide()">
            </div>
        </div>
    </div>
    </div> </div> </div>
</body>
</html>
